﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Linq.Expressions;


namespace DALScolarite
{
    public partial class scolarite_etudiants
    {
        uvtmoyEntities ent;


        public scolarite_etudiants rechetud(string cin) { 
            ent=new uvtmoyEntities();
            var query = from etudiants in ent.scolarite_etudiants
                        where etudiants.cin == cin
                        select etudiants;
            return query.First();
            
        }

        public List<scolarite_etudiants> rechercher(scolarite_etudiants e)
        {
            ent = new uvtmoyEntities();
           var query = ent.scolarite_etudiants;
           
            if(e.cin.ToString() !=""){
                query.Where(de => de.cin == e.cin); 
            }
            if (e.NomAR != "" && e.NomFR != null)
            {
                query.Where(de => de.NomFR == e.NomFR); 
            }
            return query.ToList();
                         
        }

        public scolarite_etudiants verifetudiant(string cin) { 
            
            ent = new uvtmoyEntities();
            var query = from s in ent.scolarite_etudiants
                        where s.cin == cin
                        select s;
            if (query.Any())
            {
                scolarite_etudiants res = query.First();
                return res;
            }
            else {
                return null;
            }
             

        }
    }
}
